package com.ktjy.aop;

import com.ktjy.entity.Equip;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * @author 黄军艳
 * @version 1.0
 * @date 2024/12/5  11:54
 */
@Aspect
@Component("loggerAspect")
public class LoggerAspect {
    private static final Logger log= LoggerFactory.getLogger(LoggerAspect.class);

    /**
     * 前置增强
     */
    @Before(value = "execution(* updateEquip(com.ktjy.entity.Equip))")
    public void before(JoinPoint jp){
        Equip equip= (Equip)jp.getArgs()[0];
        //判断升级的装备是否是指环
        if ("指环".equals(equip.getType())){
            //进行修改傻逼
            equip.setName("紫色梦幻"+equip.getName());
            equip.setAttackPlus(equip.getAttackPlus()+6);
            equip.setDefencePlus(equip.getDefencePlus()+6);
        }
    }
}
